package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.ActivityDao;
import com.hzqy.persistence.dao.statistics.AnswerUserDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.AwardUserVo;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.statistics.AnswerUserVo;

@Service
public class AnswerUserServiceBean extends GenericServiceBean<PmsUserVo, AnswerUserDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private AnswerUserDao answerUserDao;

	@Override
	public AnswerUserDao getEntityDao() {
		return answerUserDao;
	}
	
	public Map<String,Object> selectAnswerUserList(AnswerUserVo auv, int curPage,
			int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = answerUserDao.selectAnswerUserCount(auv);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_aqu_serverid", auv.getF_aqu_serverid());
			map.put("f_aqu_activityid", auv.getF_aqu_activityid());
			map.put("f_aqu_phone", auv.getF_aqu_phone());
			List<AnswerUserVo> results = answerUserDao.selectAnswerUserList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<AwardUserVo>());
		}
		return map;
	}
	public Map<String,Object> selectExcelList(AnswerUserVo auv) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = answerUserDao.selectExcelCount(auv);
		String status="";
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_aqu_serverid", auv.getF_aqu_serverid());
			map.put("f_aqu_activityid", auv.getF_aqu_activityid());
			map.put("f_aqu_phone", auv.getF_aqu_phone());
			List<AnswerUserVo> results = answerUserDao.selectExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<AnswerUserVo>());
		}
		return map;
	}
	
}
